<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/mb/jsp/common.jsp" %>
<%@ page import="com.limao.CacheManager.CrowdSysProjectCache" %>
<%@ page import="com.limao.DBDataClass.CrowdProjectBuyClass" %>
<%@ page import="com.limao.DBDataClass.CrowdSysDiscussDataClass" %>
<%@ page import="com.limao.DBDataClass.CrowdSysProjectClass" %>
<%@ page import="com.limao.Model.PublicData" %>
<%@ page import="com.limao.servlet.WebFunction" %>
<%@ page import="com.wsu.search.tools.Tools" %>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单详情</title>

</head>
<body ontouchstart="">
<div class="detailTop pf w100 of">
    <div class="w100 of tc c3 f18">
        <span class="pa" style="left: 2px;" onclick="javascript:history.back();"><img src="mb/images/top_back.png"
                                                                                      style="margin-top: 4px;height: 40px;width: 40px;"/></span>
        订单详情
        <!-- <div class="dib of pa" style="right: 10px;">
            <a href="mb/riskWarning.html" class="dib tc">退货说明</a>
        </div> -->
    </div>
</div>


<div id="container" class="container jz">

</div><!--container  -->




<script>
	//获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
     var orderid = getUrlParam('orderid');
      
     
     // 加载新数据
    function getData() {
     console.log(JSON.stringify({m:1679,orderid:orderid}));  
        $.ajax({
            url: "PlugServlet",
            data: JSON.stringify({m:1679,orderid:orderid}),
            type: 'post',
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            beforeSend: function () {
              showProgressDg();    
            },
            success: function (data) {
 				console.log(data.obj);
               if (data.state == 1) {
                  showData(data.obj);
                } else {
                    // 其他错误弹出提示
                    showToast(data.info);
                }
            },
            error: function (data) {
                showToast(data.info);
            },
            complete: function () {
                closeProgressDg();
            }
        });
    }
    
    //插入数据
   function showData(obj)
    {
   		var tmpimg = obj.prestigeimage.split(';');
   		
   		var introimage = obj.introimage.split(';');
   		
   		
   		if(obj.prestigeintro == ""||obj.prestigeintro == undefined||obj.prestigeintro == null){
   		   obj.prestigeintro = "暂无";
   		};
   		
   		
   		var btnDiv ="";
   		 if(obj.state== -1){
               btnDiv =
             			'<div class="fl" style="width:49.6%;">'+
						  '<a href="javascript:sendGoods('+orderid+')" class="db cf f17 tc w100">发货</a>'+
				    	'</div>'+
				    	'<div class="fr" style="width:49.6%;">'+
						   '<a href="javascript:buyBack('+orderid+')" class="db cf f17 tc w100">回购</a>'+
				    	'</div>';
			 
            } 
   		else if(obj.state== 0||obj.state== 1){
               btnDiv =
             			"";
			 
            } 
   		
   		
   		var imgList = "";
   		var dotList = "";
   		 var imgDetailList = "";
   		for (var i = 0; i < tmpimg.length; i++) {
   		
   			imgList += '<li style="float: none; display: block; position: absolute; top: 0px; left: 0px; width: 375px;"><span style="background:url('+getBaseImgUrl(tmpimg[i])+') center top no-repeat;background-size: cover" ;=""></span></li>';
   		    imgDetailList += '<img src="'+getBaseImgUrl(introimage[i])+'" class="w100 hauto" style="margin-bottom: 7px;">'
   		}
   		for (var i = 1; i < tmpimg.length; i++) {
   		    dotList += '<a href="#" class="">' + i +'</a>';
   		}
   		dotList = '<a href="#" class="on">0</a>' + dotList;
   		
   		
   		
   		
   		 	
   		var htmlStr = '<div id="imgContainer" class="main_visual_detail">'+
	   					'<div class="flicking_con w100">'+
				            '<div class="dib jz">'+
				              dotList+
				            '</div>'+
				
				        '</div>'+
				
				        '<div class="main_image_detail">'+
				            '<ul style="width: 375px; overflow: visible;">'+
								imgList +
				            '</ul>'+
				        '</div>'+
			        '</div>'+
			        '<!--main_visual_detail-->'+
			        '<section class="proSection pr w100 bcf mggt10" style="padding-bottom: 3px;">'+
				         '<div style="margin-left:3%;">'+
					         '<h5 class="c3 f13 mgt10 lh2">'+ obj.prestigename +'</h5>'+
					         '<p class="c6 f12 lh2">领取时间：'+dataToString(obj.ctime,"YYYY-MM-DD HH:mm:ss")+'</p>'+
					         '<p class="c6 f12 lh18">回购价：'+obj.callbackprice+'&nbsp;&nbsp;&nbsp;&nbsp;市场价：<span class="lineThroughSpan">'+obj.oldprice+'</span></p>'+
					         '<p class="c6 f12 lh18" style="margin-top: 3px;">数量：'+obj.num+'</p>'+
				         '</div>'+
				    '</section>'+
				     '<section class="proSection pr w100 bcf">'+
				        '<div class="detailCompany w100">'+
				            '<h4 class="f14 c3 jz">商品简介</h4>'+
				            '<p class="detailInfo c9 f12 jz">'+
				                 obj.prestigeintro +
				            '</p>'+
				        '</div>'+
				    '</section>'+
			        '<div id="introDetail" class="w100 of bcf">'+
				        '<div>'+
				            '<ul class="introTab">'+
				                '<li class="introtab_current"><span>图片简介</span></li>'+
				            '</ul>'+
				        '</div>'+
				       '<div class="introtab_content">'+
				            '<article style="display:block;">'+
				                imgDetailList +
				            '</article><!--产品-->'+
				
				        '</div>'+
				    '</div>'+
				    '<div class="detailBottm pf w100 of">'+
					    '<div class="w100 of clearfix">'+
					    	btnDiv+
					    '</div>'+
					'</div>';
   		   
       	
    	 $("#container").html(htmlStr);
    	 scollImg();
    }

  // 回购
	function buyBack(orderid) {
		var buyBackDo = function(){
			$.ajax({
	            url: "PlugServlet",
	            data: JSON.stringify({m: 1677,orderid:orderid}),
	            type: 'post',
	            dataType: 'json',
	            contentType: "application/json;charset=utf-8",
	            beforeSend: function () {
					showProgressDg();
	            },
	            success: function (data) {
	               if (data.state == 1) {
	                  // 成功弹出提示
	                  showToast(data.info);
	                  setTimeout('window.location.reload()', 1600); 
	                } else {
	                    // 其他错误弹出提示
	                   showToast(data.info);
	                }
	            },
	            error: function (data) {
	                showToast(data.info);
	            },
	            complete: function () {
	                closeProgressDg();
	            }
        	});
		}
        showTipDialog('回购', '确定回购？',buyBackDo, 3);
    } 
    
      // 发货
	function sendGoods(orderid) {
		var sendGoodsDo = function(){
			 window.location.href="mb/jsp/myAddressOrder.jsp?orderid=" + orderid +"_huigou";
		}
	
		showTipDialog('发货', '确定发货？',sendGoodsDo, 3);
    } 


function scollImg(){
 //            图片滑动
            $dragBln = false;
            $(".main_image_detail").touchSlider({
                flexible: true,
                speed: 200,
                btn_prev: $("#btn_prev"),
                btn_next: $("#btn_next"),
                paging: $(".flicking_con a"),
                counter: function (e) {
                    $(".flicking_con a").removeClass("on").eq(e.current - 1).addClass("on");
                }
            });

            $(".main_image_detail").bind("mousedown", function () {
                $dragBln = false;
            });

            $(".main_image_detail").bind("dragstart", function () {
                $dragBln = true;
            });

            $(".main_image_detail a").click(function () {
                if ($dragBln) {
                    return false;
                }
            });
            $(".main_visual_detail").hover(function () {
//                clearInterval(timer);
            }, function () {
                timer = setInterval(function () {
                    $("#btn_next").click();
                }, 5000);
            });

            $(".main_image_detail").bind("touchstart", function () {
                clearInterval(timer);
            }).bind("touchend", function () {
                timer = setInterval(function () {
                    $("#btn_next").click();
                }, 5000);
            });
            
}

$(document).ready(function () {
     getData(); 
});
        
	</script> 
</body>
</html>